The table displays the overview information of Precursor miRNAs. Each row presents one candidate pre-miRNAs with name, location in genome, strand information, abundance, and bias.
---
title: "Analysis"
date: '(`r format(Sys.time(), format = "%Y-%m-%d")`)'
output:
flexdashboard::flex_dashboard:
vertical_layout: scroll
source_code: embed
theme: cerulean
self_contained: yes
---
Quality control {data-orientation=rows data-icon="fa-area-chart"}
================================
Row
-------------------------------------
### Overview and Summary Information
```{r setup, include = FALSE}
library(DT)
library(dplyr)
library(tibble)
library(formattable)
knitr::opts_chunk$set(echo = FALSE,
message = FALSE,
warning = FALSE)
options(stringsAsFactors = F)
```
```{r }
options(stringsAsFactors = F)
info_table <- read.table("final_table.txt", sep = "\t", header = T)
info_table[info_table[, "RPM5p"]=="-", "RPM5p"] <- "0"
info_table[info_table[, "RPM3p"]=="-", "RPM3p"] <- "0"
colname_list <- c("ID", "HTcriteria", "One_class_SVM", "Source","Stem_loop_loc", "Stem_loop_len", "Stem_loop_MFE", "Stem_loop_AMFE",
"Mature_arm", "Seq5p", "Len5p", "RPM5p", "The_number_of_sequences_in_pre.miRNAs", "Abundance_bias", "Strand_bias",
"RNAfold", "Centroidfold")
df <- info_table[, colname_list]
replaceCol <- c("Mature_arm", "Seq5p", "Len5p", "RPM5p")
for(i in 1:nrow(df)){
if(info_table[i, "Mature_arm"]=="5p"){
df[i, replaceCol] <- info_table[i, replaceCol]
} else if(info_table[i, "Mature_arm"]=="3p"){
df[i, replaceCol] <- info_table[i, c("Mature_arm", "Seq3p", "Len3p", "RPM3p")]
} else {
if(as.numeric(info_table[i, "RPM5p"])>=as.numeric(info_table[i, "RPM3p"])){
df[i, replaceCol] <- c('5p', info_table[i, c("Seq5p", "Len5p", "RPM5p")])
}else{
df[i, replaceCol] <- c('3p', info_table[i, c("Seq3p", "Len3p", "RPM3p")])
}
}
}
# df <- read.table("summary_information.txt", sep = "\t", header = T)
#tissue_name <- colnames(info_table)[33:ncol(info_table)]
linkname <- gsub(":", "-", df[,5])
# for(i in 1:nrow(df)){
# df_out <- data.frame("name" = colnames(df), "value" = as.character(df[i,]))
# writeLines(jsonlite::toJSON(df_out), paste0("data/", linkname[i], ".json"))
# }
df[,1] <- paste0("", df[,1],"")
set_list <- lapply(1:3,function(cc){
formatter("span", style = x ~ style(color = ifelse(x, "green", "red")),
x ~ icontext(ifelse(x, "ok", "remove"), ifelse(x, "Yes", "No")))
})
names(set_list) <- colnames(df)[c(2,16,17)]
df <- cbind(df, "remove" = '')
df <- df %>% rowid_to_column("Row") %>% mutate(Row = "")
df <- formattable(df, set_list)
th_style = "padding: 5px;
color: #000;
text-align: center;
background-color: #ccc;
border-right-width: 1px;
border-right-style: solid;
border-right-color: white;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: white;
word-wrap: break-word;
overflow-wrap: break-word;"
table_frame <-
function() {
htmltools::withTags(
table(class = 'display', style = "padding: 1px; font-size: 0.8em;
font-family: sans-serif; text-align: center; word-wrap: break-word; overflow-wrap: break-word;",
thead(tr(
th(rowspan = 2, style = th_style, 'Row'),
th(rowspan = 2, style = th_style, 'ID'),
th(rowspan = 2, style = th_style, 'HT criteria'),
th(rowspan = 2, style = th_style, 'One class SVM'),
th(rowspan = 2, style = th_style, 'Source'),
th(class = 'dt-center', style = th_style, colspan = 4, 'Stem loop'),
th(class = 'dt-center', style = th_style, colspan = 4, 'mature miRNA'),
th(class = 'dt-center', style = th_style, colspan = 5, 'miRNA precursor'),
th(rowspan = 2, style = th_style, 'Remove'),
tr(lapply(c('Loc', 'Len', 'MFE', 'AMFE', 'Arm', 'Seq', 'Len', 'TPM',
'Seq count', 'Abundance bias', 'Strand bias',
'RNAfold', 'Centroidfold'), th, style = th_style)) #'Mean', 'Max','Sample (TPM>1)', tissue_name
)
)))
}
#th(class = 'dt-center', style = th_style, colspan = 3, 'TPM in 1063 samples'),
#th(class = 'dt-center', style = th_style, colspan = length(tissue_name), 'TPM in tissues'),
table_options <- function() {
list(dom = 'Bfrtip',
pageLength = 20,
buttons = list(c('copy', 'csv', 'excel', 'pdf', 'print')),
columnDefs = list(list(className = "select-checkbox", targets = 0, orderable = FALSE)),
select = list(style = "multi", selector = "td:first-child"),
searchHighlight = TRUE,
colReorder = TRUE,
scrollX = TRUE,
fixedColumns = TRUE,
extensions = 'Responsive',
deferRender = TRUE,
scroller = TRUE,
lengthChange = FALSE,
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': '#517fb9', 'color': '#fff'});",
"}"
)
)
}
#brks <- quantile(df[,tissue_name], probs = seq(.05, .95, .05), na.rm = TRUE)
#clrs <- round(seq(255, 40, length.out = length(brks) + 1), 0) %>%
#{paste0("rgb(255,", ., ",", ., ")")}
as.datatable(
df,
rownames = FALSE,
editable = TRUE,
elementId = "linktable",
class="compact cell-border",
# class = 'cell-border',
escape = FALSE,
container = table_frame(),
options = table_options(),
extensions = c('Buttons', 'Select'),
callback = JS("$('#linktable tbody').on('click','.btnDelete',function(){table.row( $(this).parents('tr') ).remove().draw();});")) #%>% formatStyle(tissue_name, backgroundColor = styleInterval(brks, clrs))
```
> The table displays the overview information of Precursor miRNAs. Each row presents one candidate pre-miRNAs with name, location in genome, strand information, abundance, and bias.
```{js}
function mirnaplot(event){
window.open("miRNA_out/" + event +".html");
}
```